const baseUrl = '';
const request = axios.create({
    timeout: 30000
});

request.interceptors.request.use(
    config => {
        let token = localStorage.getItem('Authorization')
        if (token) {
            //将token放到请求头发送给服务器,将tokenkey放在请求头中
            config.headers.Authorization = token;
            return config;
        }
        return config;
    },
    error => {
        return Promise.reject();
    }
);

request.interceptors.response.use(
    response => {
        if (response.status === 200) {
            return response.data;
        } else {
            Promise.reject();
        }
    },
    error => {
        return Promise.reject();
    }
);